<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./data.js"></script>
  </head>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .box {
      width: 80%;
      height: 50%;
      background-color: skyblue;
      text-align: center;
      margin: 0 auto;
    }
    .item{
        width: 80%;
        margin: 0 auto;
       display: flex; 
       flex-wrap: wrap;
       margin-bottom: 10px;
       justify-content: space-between;
    }
    li{
        width: 24%;
        border: 1px solid #000;
        list-style: none;
        margin-top: 10px;
    }
   img{
      width: 100%;
      display: block;
    }
    h1 {
      font-size: 35px;
      color: #fff;
    }
    p{
        margin-top: 5px;
        margin-bottom: 10px;
        margin-left: 5px;
    }
  </style>
  <body>
    <header class="box">
      <h1>网页头部</h1>
    </header>
    <main>
      <ul class="item">

      </ul>
    </main>
    <footer class="box">
      <h1>网页顶部</h1>
    </footer>
    <script>
      let eles = document.querySelector(".item");
      console.log(eles);
      let str = "";
      list.forEach(function (item) {
        //item就是list中的每一个对象，有多少项就执行多少次
        str += "<li>";
        str += "<div>" + `<img src= ${item.pic}>` + "</div>";
        str += "<div class='textBox'>";
        str += "<p>"+`${item.name}`+"</p>";
        str +="<p>城市:"+`${item.city}`+"</p>";
        str +="<p>地址:"+`${item.address}`+"</p>";
        str += "<p>价格:"+`${item.price}`+"</p>";
        str +="<p>演出时间:"+`${item.showTime}`+"</p>";
         str +="</div>";
      });
      eles.innerHTML = str;
    </script>
  </body>
</html>
